<%@ page language="java" import="java.util.*,entity.*,dao.*,dao.impl.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%
TopicDao topicDao = new TopicDaoImpl();
ReplyDao replyDao = new ReplyDaoImpl();
UserDao userDao = new UserDaoImpl();
BoardDao boardDao = new BoardDaoImpl();
int boardId = Integer.parseInt(request.getParameter("boardId"));
int p = Integer.parseInt(request.getParameter("page"));
List listTopic = topicDao.findListTopic(p,boardId);
Board board = boardDao.findBoard(boardId);
int prep = p;
int nextp = p;
if(listTopic.size()==20){
	nextp = p+1;
}
if(p>1){
	prep = p-1;
}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#apDiv1 {
	position: absolute;
	left: 1px;
	top: 1px;
	width: 800px;
	height: 50px;
	z-index: 1;
	text-align: center;
	font-weight: bold;
	font-size: 36px;
	color: #F00;
}
#apDiv2 {
	position: absolute;
	left: 1px;
	top: 51px;
	width: 800px;
	height: 25px;
	z-index: 2;
	font-size: 12px;
	background-color: #e0f0f9;
	color: #004c7d;
}
#apDiv3 {
	position: absolute;
	left: 1px;
	top: 76px;
	width: 800px;
	height: 500px;
	z-index: 3;
	color: #000;
}
#apDiv3 table tr td {
	font-size: 12px;
	color: #004c7d;
	
}

#apDiv3 table tr td.asdd {
	text-align: center;
}
</style>
</head>

<body>
<div id="apDiv1">校园BBS系统</div>
<div id="apDiv2">您尚未 <a href="login.jsp">登录</a>  | <a href="reg.jsp">注册</a></div>
<div id="apDiv3">
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="29" colspan="4">&gt;&gt;<a href="index.jsp">论坛首页</a>&gt;&gt;<a href="list.jsp?page=1&boardId=<%=boardId %>">
      <%=board.getBoardName() %>
      </a></td>
    </tr>
    <!-- 新帖子 -->
    <tr>
      <td height="35" colspan="4">
		<a href="post.jsp?boardId=<%=boardId %>">发表话题</a>
	  </td>
    </tr>
    <!-- 表头 -->
    <tr>
      <td colspan="2" class="asdd">文章</td>
      <td width="94">作者</td>
      <td width="40">回复</td>
    </tr>
    <!-- 主题列表 -->
    <% 
    	for(int i = 0; i < listTopic.size(); i++){
    		Topic topic = (Topic)listTopic.get(i);
			User user = userDao.findUser(topic.getUid());    	
    %>
    <tr>
      <td width="24">&nbsp;</td>
      <td width="642">
      <a href = "detail.jsp"><%=topic.getTitle() %></a>
      </td>
      <td>
      <%=user.getUName() %>
	  </td>
      <td>
      <%=replyDao.findCountReply(topic.getTopicId()) %>
	  </td>
    </tr>
    <%} %>
  </table>
  <!-- 翻页 -->
  <table width="800" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>&lt;&lt;
      <a href = "list.jsp?page=<%=prep %>&boardId=<%=boardId %>">上一页</a>&nbsp;&nbsp;
      <a href = "list.jsp?page=<%=nextp %>&boardId=<%=boardId %>">下一页</a>&gt;&gt;</td>
    </tr>
  </table>
</div>
<div align="center"></div>
<div align="center"></div>
</body>
</html>
